package com.iwayin.web.action.like;

import java.util.List;

import com.iwayin.core.bo.like.LikeBO;
import com.iwayin.core.dataobject.LikeDO;
import com.iwayin.core.dataobject.UserDO;
import com.iwayin.web.action.BaseAction;
import com.iwayin.web.common.AjaxResult;

public class LikeAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private LikeDO like;
	private List<UserDO> users;
	private AjaxResult ajaxResult;

	private LikeBO likeBO;

	/**
	 * @description 添加like
	 * @author ZhangLei
	 * @return
	 */
	public String addLike() {
		try {
			like.setUserId(this.getLoginUser().getId());
			this.likeBO.addLike(like);
			ajaxResult = AjaxResult.succResult();
		} catch (Exception e) {
			ajaxResult = AjaxResult.errorResult("添加like失败");
		}
		return SUCCESS;
	}

	/**
	 * @description 取消like
	 * @author ZhangLei
	 * @return
	 */
	public String deleteLike() {
		try {
			like.setUserId(this.getLoginUser().getId());
			this.likeBO.deleteLike(like);
			ajaxResult = AjaxResult.succResult();
		} catch (Exception e) {
			ajaxResult = AjaxResult.errorResult("取消like失败");
		}
		return SUCCESS;
	}

	/**
	 * 查询quesion的like用户列表
	 * 
	 * @return
	 */
	public String findAskLikeUsers() {
		like.setUserId(this.getLoginUser().getId());
		users = this.likeBO.findAskLikeUsers(like);
		return SUCCESS;
	}

	public void setLikeBO(LikeBO likeBO) {
		this.likeBO = likeBO;
	}

	public void setAjaxResult(AjaxResult ajaxResult) {
		this.ajaxResult = ajaxResult;
	}

	public AjaxResult getAjaxResult() {
		return ajaxResult;
	}

	public void setLike(LikeDO like) {
		this.like = like;
	}

	public LikeDO getLike() {
		return like;
	}

	public List<UserDO> getUsers() {
		return users;
	}

	public void setUsers(List<UserDO> users) {
		this.users = users;
	}

}
